﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _15.Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = @"<p>Please visit <a href=""http://academy.telerik. com"">our site</a> to choose a training course. Also visit <a href=""www.devbg.org"">our forum</a> to discuss the courses.</p>";
            Match match = Regex.Match(text, @"<a href="".*?("">)");
            while (match.Success)
            {
                string a = match.ToString();
                a = Regex.Replace(a, @"<a href=""", "[URL=");
                a = Regex.Replace(a, @""">", "]");
                text = Regex.Replace(text, match.ToString(), a);
                match = match.NextMatch();
            }
            Console.WriteLine(Regex.Replace(text, "</a>", "[/URL]"));
            //Console.WriteLine(Regex.Replace(text, "<a href=\"(.*?)\">(.*?)</a>", "[URL=$1]$2[/URL]"));
            //Console.WriteLine(Regex.Replace(text, @"<a href=""(.*?)"">(.*?)</a>", "[URL=$1]$2[/URL]"));
        }
    }
}
